;export default function () {
    window.onload = function () {
        var id = parseInt(window.location.hash.replace("#id=", ""));
        var id_index = 0;
        var li_thumb_list = Array.from($(".li-thumb"));
        // console.log(li_thumb_list);
        $.ajax({ url: "../data/products.json", dataType: "json" }).then(function (res) {
            // console.log(res.data);
            window.data = res.data;
            $.each(res.data, function (index, item) {
                if (item.productId === id) {
                    id_index = index;
                    return false;
                }
            });
            // console.log(res.data[id_index]);
            $(".img-bigshow").attr("src", res.data[id_index].productImg[0].midImg);
            $(".img-preview").attr("src", res.data[id_index].productImg[0].bigImg);
            $.each(li_thumb_list, function (index, item) {
                $($(item).children()[0]).attr("href", res.data[id_index].productImg[index].bigImg);
                $($($(item).children()[0]).children()[0]).attr({ "src": res.data[id_index].productImg[index].smallImg, "longdesc": res.data[id_index].productImg[index].midImg });
            });
            $("strong.now").html(res.data[id_index].productName);
            $("span.get-title").html('<span class="zy-mark">自营</span>' + res.data[id_index].productName);
            $(".product-abs").html(res.data[id_index].describe);
            $("#salGuidePrice").html("￥" + res.data[id_index].price);
            $(".blue").html(res.data[id_index].saleOut);
            $("#commentCount").html(res.data[id_index].evaluate);
        });
        var ls = localStorage.getItem("cart");
        if (ls !== "" && ls !== null) {
            var ls_list = JSON.parse(ls);
            var good_count = 0;
            $.each(ls_list, function (index, item) {
                good_count += item.count;
            });
            $(".js-cart-num").html(good_count);
        }
    };
    $(".all-category-box").on("mouseenter", function () {
        // alert(1);
        $(".nav_main").attr("style", "width: 192px; display: block;");
    });
    $(".all-category-box").on("mouseleave", function () {
        // alert(2);
        $(".nav_main").attr("style", "width: 192px; display: none;");
    });
    var s_width = $(".zoomplepopup").width();
    var s_height = $(".zoomplepopup").height();
    var b_width = $(".gallery-showBox").width();
    var b_height = $(".gallery-showBox").height();
    var max_x = parseInt(b_width - s_width);
    var max_y = parseInt(b_height - s_height);
    var percent = 0.3730471064032815;
    $(".gallery-showBox").on("mouseenter", function () {
        $(".zoomplepopup")["0"].style.display = "block";
        $("#probig-preview")["0"].style.visibility = "visible";
        $(".mask").attr("style", "display:block;width:" + b_width + "px;height:" + b_height + "px;position:absolute;left:0;top:0;z-index:100;cursor:move;");
    });
    $(".gallery-showBox").on("mouseleave", function () {
        $(".zoomplepopup")["0"].style.display = "none";
        $("#probig-preview")["0"].style.visibility = "hidden";
        $(".mask").attr("style", "display:none;");
    });
    // var offset_x=parseInt($(".gallery-showBox").offset().left);
    // var offset_y=parseInt($(".gallery-showBox").offset().top);
    // console.log(offset_x,offset_y);
    // console.log(width,height);
    $(".gallery-showBox").on("mousemove", function (evt) {
        var e = evt || window.event;
        // var target=e.target||e.srcElement;
        // var x=e.clientX-offset_x;
        // var y=e.clientY-offset_y+30;
        // console.log(x,y+30);
        // console.log(target);
        // if(!$(target).hasClass("img-bigshow"))  return false;
        var x = e.offsetX;
        var y = e.offsetY;
        var position_x = parseInt(x - s_width / 2);
        var position_y = parseInt(y - s_height / 2);
        position_x = position_x <= 0 ? 0 : position_x;
        position_x = position_x >= max_x ? max_x : position_x;
        position_y = position_y <= 0 ? 0 : position_y;
        position_y = position_y >= max_y ? max_y : position_y;
        $(".zoomplepopup")["0"].style.left = position_x + "px";
        $(".zoomplepopup")["0"].style.top = position_y + "px";
        $(".img-preview")["0"].style.left = -position_x / percent + "px";
        $(".img-preview")["0"].style.top = -position_y / percent + "px";
        // console.log(position_x,position_y);
        // console.log(x,y);
    });
    $(".ul-gallery-thumb").on("mouseenter", ".li-thumb", function () {
        $(this).addClass("li-now").siblings().removeClass("li-now");
        $(".img-preview")["0"].src = $($(this).children()[0]).attr("href");
        $(".img-bigshow")["0"].src = $($($(this).children()[0]).children()[0]).attr("longdesc");
    });
    $(".a-backtop").on("click", function () {
        // $("html,body").scrollTop(0);
        var speed = 2;
        var timer = setInterval(function () {
            speed += 100;
            $("html,body").scrollTop($("html,body").scrollTop() - speed);
            if ($("html,body").scrollTop() <= 0) {
                clearInterval(timer);
            }
        }, 30);
    });
}